﻿using Furion.CMS.Application.Dto;
using Furion.CMS.Domain;
using Furion.TaskScheduler;
using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Furion.CMS.Application.Profile
{
    public class CrontabProfile : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<CrontabInfo, CrontabDto>()
                .AfterMapping(dest =>
                {
                    var worker = SpareTime.GetWorker(dest.InstancePath);
                    dest.Status = (worker?.Status ?? SpareTimeStatus.CanceledOrNone).Adapt<EnumOptionDto>();
                });
        }
    }
}
